Ext.define('demo.view.book',{
	extend:'Ext.grid.Panel',
	title:'图书信息显示',
	alias:'widget.db',
	frame:true,
	forceFit : true,
	//列模式
	columns:[
		{header:'图书编号',dataIndex:'BookNum'},
		{header:'图书名称',dataIndex:'BookName'},
		{header:'出版社',dataIndex:'BookPress'},
		{header:'图书分类',dataIndex:'BookClassify'},
		{header:'图书价格',dataIndex:'BookPrice'},
		{header:'操作', xtype: 'gridcolumn',
		renderer: function(value, cellmeta, record, rowIndex, columnIndex, store) {
             var id =cellmeta.record.id;
             Ext.defer(function(){
             	Ext.widget('button',{
             		renderTo:id,
             		height:20,
             		width:50,
             		text:'删除',
             		handler:function(){
             			Ext.MessageBox.confirm('提示','确定要删除？',function(value){
             				if(value == 'yes'){
             					store.remove(record);
             				}
             			})
             			
             		}
             	})
             },50);
             return Ext.String.format('<div id="{0}"></div>', id);
          }
		}
	],
	
	//工具栏
	tbar:[
		{xtype:'button',text:'添加',id:'add'},
		{xtype:'button',text:'编辑',id:'edit'},
		{xtype:'button',text:'删除',id:'delete'},
		{xtype:'textfield',id:'dim',emptyText:'按图书名称查询'},
		{xtype:'button',text:'模糊查询',id:'query'}
	],
	
	//选择模式,多选框,使用别名
	selType:'checkboxmodel',
	multiSelect:true, //允许多选
	
	store:'bookStore',
	
	initComponent:function(){
		this.callParent(arguments);
	}
	
})



